package com.laowang.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 验证手机号的合法性
 */
public class MobileCheck {

  public static boolean isMobile(String str) {
    Pattern p = null;
    Matcher m = null;
    boolean isMatch = false;
    // 制定验证条件,目前有些新卡会出现类似166开头的,需要适当调整
    String regex2 = "^[1][3,4,5,7,8,9][0-9]{9}$";
    //String regex2 = "^((13[0-9])|(14[579])|(15([0-3,5-9]))|(16[6])|(17[0135678])|(18[0-9]|19[89]))\\d{8}$";

    p = Pattern.compile(regex2);
    m = p.matcher(str);
    isMatch = m.matches();
    return isMatch;
  }

  public static void main(String[] args) {
    String string = "15971069082";
    boolean mobile =  MobileCheck.isMobile(string);
    System.out.println(mobile);
  }
}
